package ooday05;

import java.util.ArrayList;
import java.util.List;

/** 枚举的演示 */
public class EnumDemo {
    public static void main(String[] args) {
        Season[] seasons = Season.values(); //获取所有枚举的对象
        for(int i=0;i<seasons.length;i++){
            System.out.println(seasons[i]); //输出4个枚举对象(SPRING,SUMMER,AUTUMN,WINTER)
            System.out.println(seasons[i].getSeasonName()); //输出枚举的名字属性
            System.out.println(seasons[i].getSeasonDesc()); //输出枚举的描述属性
        }

        //season的集合版本
        List<Season> season = new ArrayList<>();
        season.add(Season.SPRING);
        season.add(Season.SUMMER);
        season.add(Season.AUTUMN);
        season.add(Season.WINTER);
        System.out.println(season);
        for(int i=0;i<season.size();i++){
            Season season1 = season.get(i);
            System.out.println(season1.getSeasonName());
            System.out.println(season1.getSeasonDesc());
        }

        Season s = Season.WINTER; //获取WINTER对象，相当于Season s = Season.valueOf("WINTER");
        System.out.println(s.getSeasonName()+","+s.getSeasonDesc());
        switch(s){
            case SPRING:
                System.out.println("天气"+s.getSeasonDesc()+"放风筝去咯！");
                break;
            case SUMMER:
                System.out.println("天气"+s.getSeasonDesc()+"游戏去咯！");
                break;
            case AUTUMN:
                System.out.println("天气"+s.getSeasonDesc()+"摘苹果去咯！");
                break;
            case WINTER:
                System.out.println("天气"+s.getSeasonDesc()+"打雪仗去咯！");
                break;
        }
    }
}
